<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>留守儿童信息管理系统</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/css/layer.css" rel="stylesheet">
    <link href="/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <a  th:href="@{/index}"><img src="/images/logo-sidebar.png" title="LightYear" alt="LightYear" /></a>
            </div>
            <div class="lyear-layout-sidebar-scroll">

                <nav class="sidebar-main">
                    <ul class="nav nav-drawer">
                        <li class="nav-item"> <a th:href="@{/index}" ><i class="mdi mdi-home"></i> 后台首页</a> </li>
                        <li class="nav-item nav-item-has-subnav" id="admin">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 管理员管理</a>
                            <ul class="nav nav-subnav">
                                <li > <a th:href="@{/adminList}" >管理员列表</a> </li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="children">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 留守儿童管理</a>
                            <ul class="nav nav-subnav">
                                <li> <a th:href="@{/childrenList}">留守儿童列表</a> </li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="veteran">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 退伍军人管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/veteranList}">退伍军人列表</a></li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="elderly">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 独居老人管理</a>
                            <ul class="nav nav-subnav">
                                <li> <a th:href="@{/elderlyList}">独居老人列表</a> </li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="gift">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 礼品管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/giftList}">礼品列表</a></li>
                                <li><a th:href="@{/giftMoney}">礼品金额列表</a></li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav active open" id="community">
                            <a href="javascript:void(0)"><i class="mdi mdi-account"></i> 社区工作人员管理</a>
                            <ul class="nav nav-subnav">
                                <li class="active"> <a th:href="@{/communityList}">社区工作人员列表</a> </li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="examine">
                            <a href="javascript:void(0)"><i class="mdi mdi-email"></i> 审核管理</a>
                            <ul class="nav nav-subnav">
                                <li id="examineStatus"><a th:href="@{/regExamine}">注册审核 <span class="badge" th:text="${session.examineStatusSize}" id="examineStatusSize"></span></a></li>
                                <li id="cancellation"><a th:href="@{/cancelExamine/{userName}/(userName=${session.username})}">账号注销审核 <span class="badge" id="cancellationSize" th:text="${session.cancellationSize}"></span></a></li>
                                <li id="delChildren"><a th:href="@{/delChildrenExamine}">删除儿童信息审核 <span class="badge" th:text="${session.DelChildrenSize}" id="DelChildrenSize"></span></a></li>
                                <li id="delVeteran"><a th:href="@{/delVeteranExamine}">删除退伍军人信息审核 <span class="badge" th:text="${session.DelVeteranSize}" id="DelVeteranSize"></span></a></li>
                                <li id="delElderly"><a th:href="@{/delElderlyExamine}">删除独居老人信息审核 <span class="badge" th:text="${session.DelElderlySize}" id="DelElderlySize"></span></a></li>
                                <li id="giftExamine"><a th:href="@{/giftExamine}">礼品信息审核 <span class="badge" th:text="${session.GiftSize}" id="GiftSize"></span></a></li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="information">
                            <a href="javascript:void(0)"><i class="mdi mdi-message-draw"></i> 信息反馈</a>
                            <ul class="nav nav-subnav">
                                <li> <a th:href="@{/feedBack}">信息反馈</a> </li>
                            </ul>
                        </li>
                        <li class="nav-item nav-item-has-subnav" id="system">
                            <a href="javascript:void(0)"><i class="mdi mdi-settings"></i> 系统维护</a>
                            <ul class="nav nav-subnav">
                                <li> <a th:href="@{/notice}">系统公告</a> </li>
                                <li> <a th:href="@{/feedBackManage}">信息反馈管理</a> </li>
                            </ul>
                        </li>
                    </ul>
                </nav>

                <!--<div class="sidebar-footer">
                  <p class="copyright">Copyright &copy; 2019. All rights reserved. More Templates 更多模板：<a href="http://www.mycodes.net/" target="_blank">模板之家</a></p>
                </div>-->
            </div>

        </aside>
        <!--End 左侧导航-->

        <!--头部信息-->
        <header class="lyear-layout-header" th:fragment="top">

            <nav class="navbar navbar-default">
                <div class="topbar">

                    <div class="topbar-left">
                        <div class="lyear-aside-toggler">
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                        </div>
                        <span class="navbar-page-title"> 社区工作人员列表 </span>
                    </div>

                    <ul th:replace="~{commons::topbar-right}"></ul>

                </div>
            </nav>

        </header>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <form class="pull-right form-inline" th:action="@{/searchCommunity}" role="form">
                                    <div class="form-group">

                                        <input type="text" class="form-control col-xs-10" id="userName" name="userName"
                                               placeholder="请输入用户名">
                                        <span class="hidden-xs">&nbsp;</span>
                                        <span class="hidden-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                        <button class="btn btn-primary m-b-5" type="button" onclick="reset()"  ><i class="mdi mdi-refresh"></i> 重置</button>
                                        <button class="btn btn-success m-b-5" type="submit" ><i class="mdi mdi-magnify"></i> 搜索</button>
                                    </div>
                                </form>
                                <div class="toolbar-btn-action">
<!--                                    <a class="btn btn-primary m-b-5" th:href="@{/toCommunityAdd}"><i class="mdi mdi-plus"></i> 新增</a>-->
                                    <a class="btn btn-success m-b-5" th:onclick="enableCommunity()"><i class="mdi mdi-check"></i> 启用</a>
                                    <a class="btn btn-warning m-b-5-5" th:onclick="disableCommunity()"><i class="mdi mdi-block-helper"></i>
                                        禁用</a>
                                    <a class="btn btn-danger m-b-5" th:onclick="communityDelete2()"><i class="mdi mdi-window-close"></i> 删除</a>
                                    <a class="btn btn-success m-b-5" th:onclick="initializePwdCommunity()"><i class="mdi mdi-pencil"></i> 初始化密码</a>
                                </div>
                            </div>
                            <div class="card-body">

                                <div class="table-responsive">
                                    <table class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input type="checkbox" id="check-all"><span></span>
                                                </label>
                                            </th>
                                            <th>编号</th>
                                            <th>用户名</th>
                                            <th>姓名</th>
                                            <th>邮箱地址</th>
                                            <th>电话号码</th>
                                            <th>角色</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr th:each="communityUsers:${communityUsers}">
                                            <td>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input  type="checkbox" id="ids[]" name="ids[]" th:value="${communityUsers.getId()}"><span></span>
                                                </label>
                                            </td>
                                            <td th:text="${communityUsersStat.count}"></td>
                                            <td th:text="${communityUsers.getUserName()}"></td>
                                            <td th:text="${communityUsers.getName()}"></td>
                                            <td th:text="${communityUsers.getEmail()}"></td>
                                            <td th:text="${communityUsers.getTel()}"></td>
                                            <td th:switch = "${communityUsers.getRole()}">
                                                <div th:case="2" th:text="乡镇管理员"></div>
                                                <div th:case="0" th:text = "乡镇工作人员" ></div>
                                                <div th:case="3" th:text = "妇联管理员"></div>
                                                <div th:case="1" th:text = "妇联工作人员"></div>
                                                <div th:case="5" th:text = "军人办管理员"></div>
                                                <div th:case="4" th:text = "军人办工作人员"></div>
                                                <div th:case="7" th:text = "村委会管理员"></div>
                                                <div th:case="6" th:text = "村委会工作人员"></div>
                                            </td>
                                            <td th:switch = "${communityUsers.getStatus()}">
                                                <div th:case="1" th:text = "正常" ></div>
                                                <div th:case="0" th:text = "禁用" ></div>
                                            </td>
                                            <td >
                                                <div class="btn-group">
<!--                                                    <a class="btn btn-xs btn-default" th:href="@{/toAdminEdit/{id}/(id=${communityUsers.getId()})}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>-->
                                                    <a class="btn btn-xs btn-default" th:onclick="|communityDelete1(${communityUsers.getId()})|"  title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="modal-footer" style="height: 70px;">
                                    <div  style="width: 300px;height:50px;float: left;" class="hidden-xs">
                                        <p style="margin-top: 29px;text-align: left">当前第<b> [[${communityUsersPageInfo.pageNum}]]</b> 页,共<b> [[${communityUsersPageInfo.pages}]] </b>页.一共<b> [[${communityUsersPageInfo.total}]] </b>条记录</p>
                                    </div>

                                    <ul class="pagination hidden-xs" >
                                        <li th:if="${communityUsersPageInfo.hasPreviousPage}">
                                            <a th:href="'/searchCommunity?startPage=1'+'&userName='+${session.userName}">首页</a>
                                        </li>

                                        <li class="prev" th:if="${communityUsersPageInfo.hasPreviousPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.prePage}+'&userName='+${session.userName}">
                                                <i class="mdi mdi-chevron-left"></i>
                                            </a>
                                        </li>
                                        <!--遍历条数-->
                                        <li th:each="nav:${communityUsersPageInfo.navigatepageNums}">
                                            <a th:href="'/searchCommunity?startPage='+${nav}+'&userName='+${session.userName}" th:text="${nav}" th:if="${nav != communityUsersPageInfo.pageNum}"></a>
                                            <span style="color:white;background: #35cabb;" th:if="${nav == communityUsersPageInfo.pageNum}" th:text="${nav}" ></span>
                                        </li>

                                        <li class="next" th:if="${communityUsersPageInfo.hasNextPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.nextPage}+'&userName='+${session.userName}">
                                                <i class="mdi mdi-chevron-right"></i>
                                            </a>
                                        </li>

                                        <li th:if="${communityUsersPageInfo.hasNextPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.pages}+'&userName='+${session.userName}">尾页</a>
                                        </li>
                                    </ul>
                                    <ul class="pagination no-border visible-xs pagination-sm" style="text-align: center" >
                                        <li th:if="${communityUsersPageInfo.hasPreviousPage}">
                                            <a th:href="'/searchCommunity?startPage=1'+'&userName='+${session.userName}">首页</a>
                                        </li>

                                        <li class="prev" th:if="${communityUsersPageInfo.hasPreviousPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.prePage}+'&userName='+${session.userName}">
                                                <i class="mdi mdi-chevron-left"></i>
                                            </a>
                                        </li>
                                        <!--遍历条数-->
                                        <li th:each="nav:${communityUsersPageInfo.navigatepageNums}">
                                            <a th:href="'/searchCommunity?startPage='+${nav}+'&userName='+${session.userName}" th:text="${nav}" th:if="${nav != communityUsersPageInfo.pageNum}"></a>
                                            <span style="color:white;background: #35cabb;" th:if="${nav == communityUsersPageInfo.pageNum}" th:text="${nav}" ></span>
                                        </li>

                                        <li class="next" th:if="${communityUsersPageInfo.hasNextPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.nextPage}+'&userName='+${session.userName}">
                                                <i class="mdi mdi-chevron-right"></i>
                                            </a>
                                        </li>

                                        <li th:if="${communityUsersPageInfo.hasNextPage}">
                                            <a th:href="'/searchCommunity?startPage='+${communityUsersPageInfo.pages}+'&userName='+${session.userName}">尾页</a>
                                        </li>
                                    </ul>

                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
            <p th:text="${session.role}" id="p1" hidden></p>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<script type="text/javascript" src="/js/layer.js"></script>
<script type="text/javascript" src="js/community/communityList.js"></script>

<script type="text/javascript">
    var examineStatusSize = $("#examineStatusSize").text();
    if (examineStatusSize == 0){
        document.getElementById("examineStatusSize").style.display = "none";
    }
    var DelChildrenSize = $("#DelChildrenSize").text();
    if (DelChildrenSize == 0){
        document.getElementById("DelChildrenSize").style.display = "none";
    }
    var GiftSize = $("#GiftSize").text();
    if (GiftSize == 0){
        document.getElementById("GiftSize").style.display = "none";
    }
    var DelElderlySize = $("#DelElderlySize").text();
    if (DelElderlySize == 0){
        document.getElementById("DelElderlySize").style.display = "none";
    }
    var DelVeteranSize = $("#DelVeteranSize").text();
    if (DelVeteranSize == 0){
        document.getElementById("DelVeteranSize").style.display = "none";
    }
    var cancellationSize = $("#cancellationSize").text();
    if (cancellationSize == 0){
        document.getElementById("cancellationSize").style.display = "none";
    }
    var role = $("#p1").text();
    console.log(role)
    if (role == "0"){
        var admin = document.getElementById("admin");
        admin.style.display="none";
        document.getElementById("delElderly").style.display="none";
        document.getElementById("delVeteran").style.display="none";
        document.getElementById("delChildren").style.display="none";
    }
    if (role == "1"){
        document.getElementById("admin").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examine").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("elderly").style.display="none";
        document.getElementById("veteran").style.display="none";
        document.getElementById("veteranNum").style.display="none";
        document.getElementById("elderlyNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";


    }
    if (role == 2 ){

        document.getElementById("delChildren").style.display="none";
        document.getElementById("delVeteran").style.display="none";
        document.getElementById("delElderly").style.display="none";

    }
    if (role == "3"){

        document.getElementById("admin").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examineStatus").style.display="none";
        document.getElementById("delElderly").style.display="none";
        document.getElementById("delVeteran").style.display="none";
        document.getElementById("giftExamine").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("elderly").style.display="none";
        document.getElementById("veteran").style.display="none";
        document.getElementById("veteranNum").style.display="none";
        document.getElementById("elderlyNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";
        document.getElementById("cancellation").style.display="none";

    }
    if (role == "4"){

        document.getElementById("admin").style.display="none";
        document.getElementById("children").style.display="none";
        document.getElementById("elderly").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examine").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("childrenNum").style.display="none";
        document.getElementById("elderlyNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";

    }
    if (role == "5"){

        document.getElementById("admin").style.display="none";
        document.getElementById("children").style.display="none";
        document.getElementById("elderly").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examineStatus").style.display="none";
        document.getElementById("delElderly").style.display="none";
        document.getElementById("delChildren").style.display="none";
        document.getElementById("cancellation").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("childrenNum").style.display="none";
        document.getElementById("elderlyNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";

    }
    if (role == "6"){

        document.getElementById("admin").style.display="none";
        document.getElementById("children").style.display="none";
        document.getElementById("veteran").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examine").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("childrenNum").style.display="none";
        document.getElementById("veteranNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";

    }
    if (role == "7"){

        document.getElementById("admin").style.display="none";
        document.getElementById("children").style.display="none";
        document.getElementById("veteran").style.display="none";
        document.getElementById("community").style.display="none";
        document.getElementById("examineStatus").style.display="none";
        document.getElementById("delVeteran").style.display="none";
        document.getElementById("delChildren").style.display="none";
        document.getElementById("cancellation").style.display="none";
        document.getElementById("system").style.display="none";
        document.getElementById("adminTotal").style.display="none";
        document.getElementById("communityTotal").style.display="none";
        document.getElementById("childrenNum").style.display="none";
        document.getElementById("veteranNum").style.display="none";
        document.getElementById("giftExamine").style.display="none";

    }
</script>
</body>
</html>